package flex.ascript.ctrls
{
	import mx.collections.ArrayCollection;
	import mx.controls.dataGridClasses.DataGridColumn;
	
	public class DataGridRowNumberColumn extends DataGridColumn
	{
		private var _ownerDataGridData:ArrayCollection;
		public function DataGridRowNumberColumn(columnName:String=null)
		{
			super(columnName);
			this.headerText = "序号";
			this.width = 35;
			this.sortable = false;
			this.editable = false;
			this.labelFunction = labFun;
		}
		
		protected function labFun(item:Object, column:DataGridColumn):String
		{
			try
			{
				return (_ownerDataGridData.getItemIndex(item) + 1).toString();
			}
			catch(e:Error){
				this.visible = false;
			}
			return "0";
		}
		
		public function set ownerDataGridData(value:Object):void{
			try
			{
				this._ownerDataGridData = value as ArrayCollection;
			}
			catch(e:Error)
			{
			}
		}
	}
}